package cn.lijiguo.concurrency.part1.ch02;

import lombok.Getter;
import lombok.Setter;

/**
 * TaxCalculator
 *
 * @author lijiguo
 * @date 2019/12/6 15:47
 */
public class TaxCalculator {

    @Getter
    @Setter
    private double salary;

    @Getter
    @Setter
    private double bonus;

    @Setter
    private CalculatorStrategy calculatorStrategy;

    public TaxCalculator(double salary, double bonus) {
        this.salary = salary;
        this.bonus = bonus;
    }

    public TaxCalculator(double salary, double bonus, CalculatorStrategy calculatorStrategy) {
        this(salary, bonus);
        this.calculatorStrategy = calculatorStrategy;
    }

    protected double calcTax() {
        return calculatorStrategy.calculate(salary, bonus);
    }

    public double calculate() {
        return calcTax();
    }
}
